package com.zhang.teachingcommunity_spring.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.zhang.teachingcommunity_spring.mapper.entity.Comment;
import com.zhang.teachingcommunity_spring.mapper.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT * FROM user")
    List<User> findAll();

    @Insert("insert into user(school_id,user_type,stu_no,username,password,gender,email,phone) " +
            "VALUES (#{schoolId},#{userType},#{stuNo},#{username},#{password},#{gender},#{email},#{phone})")
    int insert(User user);

    @Select("select user_id,school_id,user_type,stu_no,username,gender,email,phone,avatar,nickname  from user where stu_no = #{stuNo} and password = #{password}")
    List<User> login(User user);
    List<Map<String, Object>> getDifferentSchoolCount();

    @Service
    interface CommentMapper extends BaseMapper<Comment> {
    }
}
